<template>
  <div class="login-page">
     <van-field type="password" label-width="120px" v-model="ruleForm.oldpass" label="原登录密码" />
     <van-field type="password" label-width="120px" v-model="ruleForm.orgpass" label="新登录密码" />
     <van-field type="password" label-width="120px" v-model="ruleForm.confirmpass" label="确认新登录密码" />
     <van-button type="primary" @click="handleSubmit">提交</van-button>
  </div>
</template>

<script>
export default {
  data() {
    return {
      ruleForm:{
        oldpass:'',
        orgpass:'',
        confirmpass:''
      },
    };
  },
  created() {
  },
  methods: {
    ruleFunc() {
      if(!this.ruleForm.oldpass) {
        this.$toast('请输入原登录密码')
      } else if(!this.ruleForm.orgpass) {
        this.$toast('请输入新登录密码')
      } else if(this.ruleForm.orgpass!=this.ruleForm.confirmpass) {
        this.$toast('两次密码不一致')
      } else {
        return true
      }
    },
    async handleSubmit() {
      if(this.ruleFunc()){
        let res = await this.$http.updateUserPass({...this.ruleForm});
        if (res) {
          this.$toast('修改成功');
        }
      }
    }
  }
};
</script>

<style>

</style>
